<?php
/**
 * url helper
 *
 * @author kim
 */
class App_View_Helper_L extends Zend_View_Helper_Url
{
    /**
     * Generate the link for view
     *
     * @access public
     *
     * @param  string|null $controller The controller name
     * @param  string|null $action The action name
     * @param  array $params The params for url
     * @param  string|null $module The module name
     * @return string Url for the link href attribute.
     */
    public function L($controller = null, $action = null, $params = array(), $module = null)
    {
        if ($this->view instanceof Zend_View) {
            $host = '';
        } else {
            $serverUrl = new Zend_View_Helper_ServerUrl();
            $host = $serverUrl->serverUrl();
        }

        /**
         * set current module
         */
        if (is_null($module) and defined('CURRENT_MODULE')) {
            $module = CURRENT_MODULE;
        }

        /**
         * url params
         */
        $p = array(
            'controller' => $controller,
            'action' => $action,
            'module' => $module,
        );

        return $host . $this->url(array_merge($p, $params), null, true);
    }
}